﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WG计划管理工具
{
    public partial class frmMain : Form
    {
        string strUserID;
        bool bSwitchUser=false;

        public frmMain(string strTmpUserID)
        {
            InitializeComponent();
            strUserID = strTmpUserID;
            this.Text = this.Text + " - " + strUserID;
        }

        private void wG计划管理ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (clsTools.VerifyPermission(strUserID, "jh1"))
            {
                frmWGJHManage newFrmWGJHManage = new frmWGJHManage(strUserID );
                newFrmWGJHManage.MdiParent = this;
                newFrmWGJHManage.WindowState = FormWindowState.Maximized;
                newFrmWGJHManage.Show();
            }
        }

        private void 入库单管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (clsTools.VerifyPermission(strUserID, "rk1"))
            {
                frmWGRKManage newFrmWGRKManage = new frmWGRKManage(strUserID );
                newFrmWGRKManage.MdiParent = this;
                newFrmWGRKManage.WindowState = FormWindowState.Maximized;
                newFrmWGRKManage.Show();
            }
        }

        private void 用户权限ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (strUserID=="DS"||clsTools.VerifyPermission(strUserID, "set1"))
            {
                frmPermissionManage newFrmPermissionManage = new frmPermissionManage();
                newFrmPermissionManage.MdiParent = this;
                newFrmPermissionManage.StartPosition = FormStartPosition.CenterParent;
                newFrmPermissionManage.Show();
            }
        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!bSwitchUser)
            {
                Application.Exit();
            }
        }

        private void 切换用户ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bSwitchUser = true;
            this.Owner .Show();
            this.Close();
        }

        private void wG申请ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (clsTools.VerifyPermission(strUserID, "sq1"))
            {
                frmWGSQManage newFrmWGSQManage = new frmWGSQManage(strUserID);
                newFrmWGSQManage.MdiParent = this;
                newFrmWGSQManage.StartPosition = FormStartPosition.CenterParent;
                newFrmWGSQManage.WindowState = FormWindowState.Maximized;
                newFrmWGSQManage.Show();
            }
        }

        private void 计划查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmWGJHBrowse newFrmWGJHBrowse = new frmWGJHBrowse();
            newFrmWGJHBrowse.MdiParent = this;
            newFrmWGJHBrowse.StartPosition = FormStartPosition.CenterParent;
            newFrmWGJHBrowse.Show();
        }

        private void 出库单管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (clsTools.VerifyPermission(strUserID, "ck1"))
            {
                frmWGCKManage newFrmWGCKManage = new frmWGCKManage(strUserID);
                newFrmWGCKManage.MdiParent = this;
                newFrmWGCKManage.StartPosition = FormStartPosition.CenterParent;
                newFrmWGCKManage.Show();
            }
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void wG库存ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmWGKCSearch newFrmWGKCSearch = new frmWGKCSearch();
            newFrmWGKCSearch.MdiParent = this;
            newFrmWGKCSearch.StartPosition = FormStartPosition.CenterParent;
            newFrmWGKCSearch.Show();
        }

        private void 计划单号设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmJHNoSet newFrmJHNoSet = new frmJHNoSet();
            newFrmJHNoSet.ShowDialog();
        }
    }
}